package com.hopes.bizz.risk.hid.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.common.core.validate.group.AddGroup;
import com.hopes.bizz.common.core.validate.group.UpdateGroup;
import com.hopes.bizz.risk.common.constant.enums.RiskModDictEnum;
import com.hopes.bizz.risk.common.constant.enums.RiskSysDictEnum;
import com.hopes.bizz.risk.hid.entity.RiskHidHiddenDangerEntity;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.Optional;

/**
 * @author: ljh
 * @create: 2023/8/2
 */
@Data
@NoArgsConstructor
public class RiskHidHiddenDangerVO {


    public RiskHidHiddenDangerVO(RiskHidHiddenDangerEntity riskHidHiddenDangerEntity) {
        this.id = riskHidHiddenDangerEntity.getId();
        this.hazardCode = riskHidHiddenDangerEntity.getHazardCode();
        this.riskControlId = riskHidHiddenDangerEntity.getRiskControlId();
        this.riskUnitId = riskHidHiddenDangerEntity.getRiskUnitId();
        this.checkRecordId = riskHidHiddenDangerEntity.getCheckRecordId();
        this.bizCode = riskHidHiddenDangerEntity.getBizCode();
        this.bizId = riskHidHiddenDangerEntity.getBizId();
        this.bizName = riskHidHiddenDangerEntity.getBizName();
        this.hidAreaId = riskHidHiddenDangerEntity.getHidAreaId();
        this.auditStatus = riskHidHiddenDangerEntity.getAuditStatus();
        this.hidStatus = riskHidHiddenDangerEntity.getHidStatus();
        this.delayStatus = riskHidHiddenDangerEntity.getDelayStatus();
        this.hidCode = riskHidHiddenDangerEntity.getHidCode();
        this.hidName = riskHidHiddenDangerEntity.getHidName();
        this.hidSource = riskHidHiddenDangerEntity.getHidSource();
        this.hidType = riskHidHiddenDangerEntity.getHidType();
        this.hidCategory = riskHidHiddenDangerEntity.getHidCategory();
        this.hidContent = riskHidHiddenDangerEntity.getHidContent();
        this.hidLevel = riskHidHiddenDangerEntity.getHidLevel();
        this.hidReason = riskHidHiddenDangerEntity.getHidReason();
        this.hidLocation = riskHidHiddenDangerEntity.getHidLocation();
        this.cost = riskHidHiddenDangerEntity.getCost();
        this.deptId = riskHidHiddenDangerEntity.getDeptId();
        this.principal = riskHidHiddenDangerEntity.getPrincipal();
        this.reportUser = riskHidHiddenDangerEntity.getReportUser();
        this.reportDeptId = riskHidHiddenDangerEntity.getReportDeptId();
        this.reportDate = riskHidHiddenDangerEntity.getReportDate();
        this.reportPhoto = riskHidHiddenDangerEntity.getReportPhoto();
        this.reportVideo = riskHidHiddenDangerEntity.getReportVideo();
        this.confirmUserId = riskHidHiddenDangerEntity.getConfirmUserId();
        this.assignFlag = riskHidHiddenDangerEntity.getAssignFlag();
        this.correctiveWay = riskHidHiddenDangerEntity.getCorrectiveWay();
        this.correctiveDesc = riskHidHiddenDangerEntity.getCorrectiveDesc();
        this.correctiveDeadline = riskHidHiddenDangerEntity.getCorrectiveDeadline();
        this.correctiveUser = riskHidHiddenDangerEntity.getCorrectiveUser();
        this.correctiveAdviceDesc = riskHidHiddenDangerEntity.getCorrectiveAdviceDesc();
        this.correctiveReportDesc = riskHidHiddenDangerEntity.getCorrectiveReportDesc();
        this.correctiveReportPhoto = riskHidHiddenDangerEntity.getCorrectiveReportPhoto();
        this.checkUser = riskHidHiddenDangerEntity.getCheckUser();
        this.checkTime = riskHidHiddenDangerEntity.getCheckTime();
        this.checkDesc = riskHidHiddenDangerEntity.getCheckDesc();
        this.checkUserSignature = riskHidHiddenDangerEntity.getCheckUserSignature();
        this.remarks = riskHidHiddenDangerEntity.getRemarks();
        this.longitude = riskHidHiddenDangerEntity.getLongitude();
        this.latitude = riskHidHiddenDangerEntity.getLatitude();
        this.orgId = riskHidHiddenDangerEntity.getOrgId();
    }

    /**
     * 标识
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "标识")
    private Long id;

    /**
     * 风险对象编码
     */
    @Schema(description = "风险对象编码")
    private String hazardCode;

    /**
     * 管控措施ID
     */
    @Schema(description = "管控措施ID")
    private Long riskControlId;

    /**
     * 风险单元id
     */
    @Schema(description = "风险单元id")
    private Long riskUnitId;

    /**
     * 隐患排查记录ID
     */
    @Schema(description = "隐患排查记录ID")
    private Long checkRecordId;

    /**
     * 源业务编码
     */
    @Schema(description = "源业务编码")
    private String bizCode;

    /**
     * 源业务标识
     */
    @Schema(description = "源业务标识")
    private String bizId;

    /**
     * 源业务名称
     */
    @Schema(description = "源业务名称")
    private String bizName;
    /**
     * 区域标识
     */
    @Schema(description = "区域标识")
    private Long hidAreaId;

    /**
     * 审核状态  正常、驳回、转办、撤销
     */
    @Schema(description = "审核状态")
    private Integer auditStatus;

    /**
     * 待提交 10  待确认 20 待整改 30 待验收 40 验收通过 100
     */
    @Schema(description = "隐患状态")
    private Integer hidStatus;

    /**
     * 延期状态 0 正常 1 延期申请中 2 延期
     */
    @Schema(description = "延期状态")
    private Integer delayStatus;

    /**
     * 隐患编码   HID_202304041553_1
     */
    @Schema(description = "隐患编码")
    private String hidCode;

    /**
     * 隐患名称
     */
    @Schema(description = "隐患名称")
    private String hidName;

    /**
     * 隐患来源
     */
    @Schema(description = "隐患来源")
    private Integer hidSource;

    /**
     * 隐患类型
     */
    @Schema(description = "隐患类型")
    private Integer hidType;


    /**
     * 隐患类别（其他隐患：0 主要负责人隐患：1 技术负责人隐患：2 操作负责人隐患：3）默认为其他隐患：0
     */
    @Schema(description = "隐患类别")
    private Integer hidCategory;

    /**
     * 隐患描述
     */
    @Schema(description = "隐患描述")
    private String hidContent;

    /**
     * 隐患等级
     */
    @Schema(description = "隐患等级")
    private Integer hidLevel;

    /**
     * 原因分析
     */
    @Schema(description = "原因分析")
    private String hidReason;

    /**
     * 位置
     */
    @Schema(description = "位置")
    private String hidLocation;

    /**
     * 资金(万元)
     */
    @Schema(description = "资金(万元)")
    private String cost;

    /**
     * 责任部门
     */
    @Schema(description = "责任部门")
    private Long deptId;

    /**
     * 整改负责人
     */
    @Schema(description = "整改负责人")
    private String principal;
    /**
     * 上报人员
     */
    @Schema(description = "上报人员")
    private String reportUser;
    /**
     * 上报部门
     */
    @Schema(description = "上报部门")
    private Long reportDeptId;
    /**
     * 上报日期
     */
    @Schema(description = "上报日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date reportDate;
    /**
     * 上报图片
     */
    @Schema(description = "上报图片")
    private String reportPhoto;
    /**
     * 上报视频
     */
    @Schema(description = "上报视频")
    private String reportVideo;
    /**
     * 确认人
     */
    @Schema(description = "确认人")
    private Long confirmUserId;
    /**
     * 是否直接指派
     */
    @Schema(description = "是否直接指派")
    private Boolean assignFlag;
    /**
     * 整改方式 1:立即整改   2:限期整改
     */
    @Schema(description = "整改方式")
    private Integer correctiveWay;

    /**
     * 整改措施
     */
    @Schema(description = "整改措施")
    private String correctiveDesc;

    /**
     * 整改期限
     */
    @Schema(description = "整改期限")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date correctiveDeadline;

    /**
     * 整改人
     */
    @Schema(description = "整改人")
    private String correctiveUser;

    /**
     * 整改建议
     */
    @Schema(description = "整改建议")
    private String correctiveAdviceDesc;
    /**
     * 整改说明
     */
    @Schema(description = "整改说明")
    private String correctiveReportDesc;
    /**
     * 整改图片
     */
    @Schema(description = "整改图片")
    private String correctiveReportPhoto;

    /**
     * 验收人
     */
    @Schema(description = "验收人")
    private String checkUser;
    /**
     * 验收时间
     */
    @Schema(description = "验收时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date checkTime;

    /**
     * 验收情况
     */
    @Schema(description = "验收情况")
    @NotBlank(message = "验收情况为必填项", groups = {AddGroup.class, UpdateGroup.class})
    @Length(max = 1000, message = "验收情况最大长度为:1000", groups = {AddGroup.class, UpdateGroup.class})
    private String checkDesc;

    /**
     * 验收人签名
     */
    @Schema(description = "验收人签名")
    private String checkUserSignature;

    /**
     * 备注
     */
    @Schema(description = "备注")
    private String remarks;

    /**
     * 经度
     */
    @Schema(description = "经度")
    private String longitude;

    /**
     * 纬度
     */
    @Schema(description = "纬度")
    private String latitude;

    /**
     * 企业标识
     */
    @Schema(description = "企业标识")
    private Long orgId;


    public String getHidSourceStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.hidden_danger_check_type_and_source, this.hidSource);
    }

    public String getHidLevelStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.danger_level, this.hidLevel);
    }

    public String getDeptIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_dept, this.deptId);
    }

    public String getReportDeptIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_dept, this.reportDeptId);
    }

    public String getPrincipalStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_user, this.principal);
    }

    public String getHidStatusStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.hidden_danger_status, this.hidStatus);
    }

    public String getCorrectiveWayStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.hid_corrective_way, this.correctiveWay);
    }

    public String getHidTypeStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.danger_type, this.hidType);
    }

    public String getAuditStatusStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.hidden_danger_audit_status, this.getAuditStatus());
    }

    public String getRiskUnitIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_unit, Optional.ofNullable(this.riskUnitId).map(String::valueOf).orElse(null));
    }

    public String getDelayStatusStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.hidden_delay_status, this.delayStatus.toString());

    }

    public String getReportDateDayStr() {
        return DateUtils.limitDay(this.reportDate);
    }

    public String getOrgIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, orgId);
    }
}
